package com.esr.test;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    private EditText input;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button button = this.findViewById(R.id.checkme);
        input = this.findViewById(R.id.input);

        button.setOnClickListener(new buttonListener());

        Intent intent = getIntent();
        if(intent!=null){
            String str = intent.getStringExtra("CALL_NUMBER");
            if(str!=null&&str.length()>0){
                Log.i("CALL_NUMBER",str);
            }

        }


    }


    private class buttonListener implements View.OnClickListener{

        @Override
        public void onClick(View view) {
            String phone = input.getText().toString();
            Intent intent = new Intent();
            intent.setAction("android.intent.action.CALL");
            intent.setData(Uri.parse("tel:"+phone));
            startActivity(intent);
        }
    }
}
